const users = [
  { name: 'admin', password: '123456', token: 'admin', info: {
      name: '系统管理员'
    }},
  { name: 'editor', password: '123456', token: 'editor', info: {
      name: '编辑人员'
    }},
  { name: 'test', password: '123456', token: 'test', info: {
      name: '测试人员'
    }},
]
export default [
  {
    url: `/mock/user/login`,
    method: 'post',
    response: ({ body }) => {
      const user = users.find(user => {
        return body.name === user.name && body.password === user.password
      })
      if (user) {
        return {
          code: 200,
          data: {
            token: user.token,
          },
        };
      } else {
        return {
          code: 401,
          data: {},
          msg: '用户名或密码错误'
        };
      }

    }
  },
  {
    url: `/mock/user/info`,
    method: 'get',
    response: (request) => {
      const token  = request.headers.token;;
      if (token){
        return {
          code: 200,
          data: users[0],
          msg: 'success'
        };
      } else{
        return "还没登录"
      }
    }
  }
]